package com.dc.service.impl;

import java.util.List;

import com.dc.dao.CommentsDao;
import com.dc.dao.impl.CommentsDaoImpl;
import com.dc.entity.Comments;
import com.dc.service.CommentsService;
import com.dc.tools.PageData;
/**
 * 实现CommentsService接口的方法
 * @author jesslos
 *
 */
public class CommentsServiceImpl implements CommentsService {
	CommentsDao cd = new CommentsDaoImpl();
	/**
	 * 增加评价
	 */
	@Override
	public boolean addComments(Comments comments) {
		// TODO Auto-generated method stub
		if (comments == null) {
			return cd.addComments(comments);
		}
		//调用增加的方法
		return false;
	}
	/**
	 * 删除评价
	 */
	@Override
	public boolean deleteComments(int commentsid) {
		// TODO Auto-generated method stub
		return cd.deleteComments(commentsid);
	}
	/**
	 * 修改评价
	 */
	@Override
	public boolean updateComments(Comments comments) {
		// TODO Auto-generated method stub
		return cd.updateComments(comments);
	}
	/**
	 * 根据关键字查找
	 */
	@Override
	public List<Comments> selectCommentsByLike(String keywords) {
		// TODO Auto-generated method stub
		return cd.selectCommentsByLike(keywords);
	}
	/**
	 * 查找所有评价
	 */
	@Override
	public List<Comments> selectComments() {
		// TODO Auto-generated method stub
		return cd.selectComments();
	}
	/**
	 * 分页显示
	 */
	@Override
	public PageData<Comments> selectCommentsByPage(int page, int pageSize, String keywords) {
		// TODO Auto-generated method stub
		if(page<1) {
			page=1;
		}
		return cd.selectCommentsByPage(page, pageSize, keywords);
	}
	/**
	 * 按照订单编号查询出评价 用于商家的订单/评价管理
	 */
	@Override
	public PageData<Comments> selectCommentsByShopName(int page, int pageSize, int shopid, String commentsinfo) {
		// TODO Auto-generated method stub
		return cd.selectCommentsByShopName(page, pageSize, shopid,"%"+commentsinfo+"%");
	}
	
	
	@Override
	public boolean addCommentsByShop(String shopanswer,int shopid) {
		// TODO Auto-generated method stub
		return cd.addCommentsByShop(shopanswer, shopid);
	}

}
